package main;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JPanel;

/**
 * Panel z motywem gry
 * @author Maciej Krawczyk
 */
@SuppressWarnings("serial")
public class ThemePanel extends JPanel {
	
	/**Obrazek z motywem gry*/
	private BufferedImage image;
	
	/**Konstruktor panelu z motywem gry*/
	public ThemePanel() {

		File imageFile = new File("badugi_theme.jpg");
		try {
			image = ImageIO.read(imageFile);
		} catch (IOException e) {
			System.err.println("Blad odczytu obrazka");
			e.printStackTrace();
		}
		
		Dimension dimension = new Dimension(image.getWidth(), image.getHeight());
		setPreferredSize(dimension);
	}
	
	/**Narysowanie motywu gry*/
	@Override
	public void paintComponent(Graphics g) {
		Graphics2D g2d = (Graphics2D) g;
		g2d.drawImage(image, 0, 0, this);
	}
}
